<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Mac OS上搭建Hexo博客流程 | CodingDGSun's Blog</title><meta name="author" content="CodingDGSun"><meta name="copyright" content="CodingDGSun"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Hexo 介绍 https:&#x2F;&#x2F;hexo.io https:&#x2F;&#x2F;hexo.io&#x2F;zh-cn&#x2F;  环境准备安装nodejs 下载地址：https:&#x2F;&#x2F;nodejs.org&#x2F;en&#x2F; 以：node-v14.17.1.pkg 为例   打开终端，切换root用户比如：打开terminal或者iterms终端软件，执行以下命令 12&#x2F;&#x2F;切换到root用户sudo su   安装淘宝镜像12&#x2F;&#x2F;使用npm安装">
<meta property="og:type" content="article">
<meta property="og:title" content="Mac OS上搭建Hexo博客流程">
<meta property="og:url" content="https://sunjie23.gitee.io/codingdgsun/2021/06/28/Mac%20OS%E4%B8%8A%E6%90%AD%E5%BB%BAHexo%E5%8D%9A%E5%AE%A2%E6%B5%81%E7%A8%8B/index.html">
<meta property="og:site_name" content="CodingDGSun&#39;s Blog">
<meta property="og:description" content="Hexo 介绍 https:&#x2F;&#x2F;hexo.io https:&#x2F;&#x2F;hexo.io&#x2F;zh-cn&#x2F;  环境准备安装nodejs 下载地址：https:&#x2F;&#x2F;nodejs.org&#x2F;en&#x2F; 以：node-v14.17.1.pkg 为例   打开终端，切换root用户比如：打开terminal或者iterms终端软件，执行以下命令 12&#x2F;&#x2F;切换到root用户sudo su   安装淘宝镜像12&#x2F;&#x2F;使用npm安装">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg">
<meta property="article:published_time" content="2021-06-28T05:34:54.000Z">
<meta property="article:modified_time" content="2021-06-28T06:08:34.961Z">
<meta property="article:author" content="CodingDGSun">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg"><link rel="shortcut icon" href="/codingdgsun/img/favicon.png"><link rel="canonical" href="https://sunjie23.gitee.io/codingdgsun/2021/06/28/Mac%20OS%E4%B8%8A%E6%90%AD%E5%BB%BAHexo%E5%8D%9A%E5%AE%A2%E6%B5%81%E7%A8%8B/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/codingdgsun/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/codingdgsun/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Mac OS上搭建Hexo博客流程',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-06-28 14:08:34'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/codingdgsun/atom.xml" title="CodingDGSun's Blog" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/头像.7horht40yvwg.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/codingdgsun/archives/"><div class="headline">Articles</div><div class="length-num">59</div></a></div></div></div><hr/></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/codingdgsun/">CodingDGSun's Blog</a></span><div id="menus"><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Mac OS上搭建Hexo博客流程</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2021-06-28T05:34:54.000Z" title="Created 2021-06-28 13:34:54">2021-06-28</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2021-06-28T06:08:34.961Z" title="Updated 2021-06-28 14:08:34">2021-06-28</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Mac OS上搭建Hexo博客流程"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post View:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Hexo-介绍"><a href="#Hexo-介绍" class="headerlink" title="Hexo 介绍"></a>Hexo 介绍</h1><ul>
<li><a target="_blank" rel="noopener" href="https://hexo.io/">https://hexo.io</a></li>
<li><a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/">https://hexo.io/zh-cn/</a></li>
</ul>
<h1 id="环境准备"><a href="#环境准备" class="headerlink" title="环境准备"></a>环境准备</h1><h3 id="安装nodejs"><a href="#安装nodejs" class="headerlink" title="安装nodejs"></a>安装nodejs</h3><ul>
<li>下载地址：<a target="_blank" rel="noopener" href="https://nodejs.org/en/">https://nodejs.org/en/</a></li>
<li>以：node-v14.17.1.pkg 为例</li>
</ul>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_01.344qt8dlu3k0.jpg" alt="02_01"></p>
<h3 id="打开终端，切换root用户"><a href="#打开终端，切换root用户" class="headerlink" title="打开终端，切换root用户"></a>打开终端，切换root用户</h3><p>比如：打开terminal或者iterms终端软件，执行以下命令</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">//切换到root用户</span><br><span class="line">sudo su </span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_02.6amckzogkruo.jpg" alt="02_02"></p>
<h3 id="安装淘宝镜像"><a href="#安装淘宝镜像" class="headerlink" title="安装淘宝镜像"></a>安装淘宝镜像</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">//使用npm安装相关依赖包，速度很慢，建议安装淘宝镜像，后续命令使用cnpm</span><br><span class="line">npm install -g cnpm --registry=https://registry.npm.taobao.org </span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_03.5tc5lifiafls.jpg" alt="02_03"></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_04.2spyb0ysy740.jpg" alt="02_04"></p>
<h1 id="安装Hexo"><a href="#安装Hexo" class="headerlink" title="安装Hexo"></a>安装Hexo</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">//安装hexo</span><br><span class="line">cnpm install -g hexo-cli </span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_05.58i94pfret1c.jpg" alt="02_05"></p>
<h3 id="Hexo安装成功"><a href="#Hexo安装成功" class="headerlink" title="Hexo安装成功"></a>Hexo安装成功</h3><p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_06.6ycmfpg4bk74.jpg" alt="02_06"></p>
<h1 id="初始化博客网站"><a href="#初始化博客网站" class="headerlink" title="初始化博客网站"></a>初始化博客网站</h1><h3 id="新建项目文件夹，并进入文件夹内"><a href="#新建项目文件夹，并进入文件夹内" class="headerlink" title="新建项目文件夹，并进入文件夹内"></a>新建项目文件夹，并进入文件夹内</h3><p>比如：Blog。后续如果项目出现问题，或者想重新创建，只需要删除此文件夹，即可</p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_07.4reuq9t9tri8.jpg" alt="02_07"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">//初始化项目（必须进入到项目文件夹里面后，执行此命令）</span><br><span class="line">sudo hexo init </span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_08.5d0f9azh381s.jpg" alt="02_08"></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_09.31dzh1zlzjwg.jpg" alt="02_09"></p>
<h3 id="启动hexo"><a href="#启动hexo" class="headerlink" title="启动hexo"></a>启动hexo</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">//启动hexo</span><br><span class="line">hexo s </span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_10.61sswu7jx1j4.jpg" alt="02_10"></p>
<h3 id="浏览器打开博客网站"><a href="#浏览器打开博客网站" class="headerlink" title="浏览器打开博客网站"></a>浏览器打开博客网站</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 浏览器打开</span><br><span class="line">http://localhost:4000 </span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_11.2tiwg6bl801s.jpg" alt="02_11"></p>
<h3 id="创建博客，并写博客"><a href="#创建博客，并写博客" class="headerlink" title="创建博客，并写博客"></a>创建博客，并写博客</h3><ul>
<li>Vim命令的使用，可以参考<a target="_blank" rel="noopener" href="https://www.runoob.com/linux/linux-vim.html">这里</a><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">//创建文章</span><br><span class="line">hexo n &quot;我的第一篇博客文章&quot; </span><br><span class="line">//编辑文章</span><br><span class="line">vim 我的第一篇博客文章.md </span><br></pre></td></tr></table></figure></li>
</ul>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_12.l7we2eb24qo.jpg" alt="02_12"></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_13.7d9n93k0blds.jpg" alt="02_13"></p>
<h1 id="项目管理执行"><a href="#项目管理执行" class="headerlink" title="项目管理执行"></a>项目管理执行</h1><h3 id="清理项目缓存"><a href="#清理项目缓存" class="headerlink" title="清理项目缓存"></a>清理项目缓存</h3><ul>
<li>新增博客文章或者修改博客文章内容，需要执行此命令<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 清理之前生成的网站</span><br><span class="line">hexo clean </span><br></pre></td></tr></table></figure></li>
</ul>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_14.5noc25pm114w.jpg" alt="02_14"></p>
<h3 id="重新生成项目"><a href="#重新生成项目" class="headerlink" title="重新生成项目"></a>重新生成项目</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 重新生成博客项目</span><br><span class="line">hexo g </span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_15.4dssqjgeco00.jpg" alt="02_15"></p>
<h3 id="再次启动项目"><a href="#再次启动项目" class="headerlink" title="再次启动项目"></a>再次启动项目</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 再次启动博客网站</span><br><span class="line">hexo s </span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_16.4xty5eytqbuo.jpg" alt="02_16"></p>
<h1 id="修改主题"><a href="#修改主题" class="headerlink" title="修改主题"></a>修改主题</h1><h3 id="选择主题"><a href="#选择主题" class="headerlink" title="选择主题"></a>选择主题</h3><p>大家可以按照自己的需要下载适合的主题。可以从官网<a target="_blank" rel="noopener" href="https://hexo.io/themes/">下载</a><br>比如：选择 <a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly.git">butterfly</a></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_23.2sktzc9mm6io.jpg" alt="02_23"></p>
<h3 id="下载主题代码"><a href="#下载主题代码" class="headerlink" title="下载主题代码"></a>下载主题代码</h3><ul>
<li>在项目根目录下，即”Blog“文件夹下执行以下命令，<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// clone主题代码到 themes/butterfly</span><br><span class="line">git clone https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly</span><br></pre></td></tr></table></figure></li>
</ul>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_24.33kglpg1v79c.jpg" alt="02_24"></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_25.34jbfezttcg0.jpg" alt="02_25"></p>
<h3 id="修改项目配置文件，配置主题"><a href="#修改项目配置文件，配置主题" class="headerlink" title="修改项目配置文件，配置主题"></a>修改项目配置文件，配置主题</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 修改配置文件，主题主题</span><br><span class="line">vim _config.yml </span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_20.16yhp6c3fa68.jpg" alt="02_20"></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_21.3szs67w4bsw0.jpg" alt="02_21"></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_26.1bldz0u938ao.jpg" alt="02_26"></p>
<h3 id="在项目目录下执行以下命令【非常重要，亲测有效】"><a href="#在项目目录下执行以下命令【非常重要，亲测有效】" class="headerlink" title="在项目目录下执行以下命令【非常重要，亲测有效】"></a>在项目目录下执行以下命令【非常重要，亲测有效】</h3><p>此坑解决方案来源于<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/137946156">这里</a>：<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/137946156">https://zhuanlan.zhihu.com/p/137946156</a></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive</span><br></pre></td></tr></table></figure>

<h3 id="重新生成项目-1"><a href="#重新生成项目-1" class="headerlink" title="重新生成项目"></a>重新生成项目</h3><ul>
<li>具体操作过程，前面章节已经介绍<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo clean</span><br><span class="line">hexo g</span><br><span class="line">hexo s</span><br></pre></td></tr></table></figure>
<h3 id="重新运行项目"><a href="#重新运行项目" class="headerlink" title="重新运行项目"></a>重新运行项目</h3><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_27.731s8khtqubk.jpg" alt="02_27"><br>新的主题界面<br><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_28.q5mkxxcvj40.jpg" alt="02_28"></li>
</ul>
<p>后续可以根据自己需求，修改主题界面，优化界面。</p>
<h1 id="将博客部署到云端（GitHub上，需要有自己的账户）"><a href="#将博客部署到云端（GitHub上，需要有自己的账户）" class="headerlink" title="将博客部署到云端（GitHub上，需要有自己的账户）"></a>将博客部署到云端（<a target="_blank" rel="noopener" href="https://github.com/">GitHub</a>上，需要有自己的账户）</h1><h3 id="新建仓库"><a href="#新建仓库" class="headerlink" title="新建仓库"></a>新建仓库</h3><p>登录：<a target="_blank" rel="noopener" href="https://github.com/">https://github.com</a><br>新建仓库，必须是【public】公共的仓库。</p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_31.3ppq2lxnnc74.jpg" alt="02_31"></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_30.6chazck33i80.jpg" alt="02_30"></p>
<p>创建成功<br>此案例的仓库地址：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://github.com/CodingDGSun/CodingDGSun.github.io.git</span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_32.66yb4uq9z4w0.jpg" alt="02_32"></p>
<h3 id="在项目目录下执行以下命令"><a href="#在项目目录下执行以下命令" class="headerlink" title="在项目目录下执行以下命令"></a>在项目目录下执行以下命令</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cnpm install --save hexo-deployer-git</span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_29.f2gcn15c8y8.jpg" alt="02_29"></p>
<h3 id="修改配置文件"><a href="#修改配置文件" class="headerlink" title="修改配置文件"></a>修改配置文件</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 修改配置</span><br><span class="line">vim _config.yml </span><br></pre></td></tr></table></figure>

<p>修改文件最后位置<br>其中【repo】就填写刚刚新建的仓库地址。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">type: git</span><br><span class="line">repo: https://github.com/CodingDGSun/CodingDGSun.github.io.git</span><br><span class="line">branch: master</span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_33.3lyqa6vtlzls.jpg" alt="02_33"></p>
<h3 id="部署项目到云端"><a href="#部署项目到云端" class="headerlink" title="部署项目到云端"></a>部署项目到云端</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 执行部署命令</span><br><span class="line">hexo d 部署</span><br></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_34.3iq8wbwrbohs.jpg" alt="02_34"></p>
<h3 id="访问云端博客主页"><a href="#访问云端博客主页" class="headerlink" title="访问云端博客主页"></a>访问云端博客主页</h3><p>访问地址，就是https://新建仓库的名称+.github.io<br>比如此案例是:<a target="_blank" rel="noopener" href="https://codingdgsun.github.io/">https://CodingDGSun.github.io</a></p>
<p><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/02_35.1fs1dbt4dp8g.jpg" alt="02_35"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">Author: </span><span class="post-copyright-info"><a href="mailto:undefined">CodingDGSun</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">Link: </span><span class="post-copyright-info"><a href="https://sunjie23.gitee.io/codingdgsun/2021/06/28/Mac%20OS%E4%B8%8A%E6%90%AD%E5%BB%BAHexo%E5%8D%9A%E5%AE%A2%E6%B5%81%E7%A8%8B/">https://sunjie23.gitee.io/codingdgsun/2021/06/28/Mac%20OS%E4%B8%8A%E6%90%AD%E5%BB%BAHexo%E5%8D%9A%E5%AE%A2%E6%B5%81%E7%A8%8B/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">Copyright Notice: </span><span class="post-copyright-info">All articles in this blog are licensed under <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> unless stating additionally.</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/codingdgsun/2021/06/28/Java%E5%BC%80%E5%8F%91%E5%AD%A6%E4%B9%A0%E4%B9%8B%E8%B7%AF/"><img class="prev-cover" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="onerror=null;src='/codingdgsun/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">Previous Post</div><div class="prev_info">Java开发学习之路</div></div></a></div><div class="next-post pull-right"><a href="/codingdgsun/2021/06/27/Windows%E4%B8%8A%E5%B8%B8%E7%94%A8Dos%E5%91%BD%E4%BB%A4%EF%BC%88%E9%80%82%E5%90%88%E5%88%9D%E5%AD%A6%E8%80%85%EF%BC%89/"><img class="next-cover" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="onerror=null;src='/codingdgsun/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">Next Post</div><div class="next_info">Windows上常用Dos命令（适合初学者）</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://cdn.jsdelivr.net/gh/CodingDGSun/images-db@master/Blog/头像.7horht40yvwg.jpg" onerror="this.onerror=null;this.src='/codingdgsun/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">CodingDGSun</div><div class="author-info__description"></div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/codingdgsun/archives/"><div class="headline">Articles</div><div class="length-num">59</div></a></div></div><a class="button--animated" id="card-info-btn" href="https://sunjie23.gitee.io/codingdgsun"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>Announcement</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>Catalog</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Hexo-%E4%BB%8B%E7%BB%8D"><span class="toc-number">1.</span> <span class="toc-text">Hexo 介绍</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%8E%AF%E5%A2%83%E5%87%86%E5%A4%87"><span class="toc-number">2.</span> <span class="toc-text">环境准备</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85nodejs"><span class="toc-number">2.0.1.</span> <span class="toc-text">安装nodejs</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%89%93%E5%BC%80%E7%BB%88%E7%AB%AF%EF%BC%8C%E5%88%87%E6%8D%A2root%E7%94%A8%E6%88%B7"><span class="toc-number">2.0.2.</span> <span class="toc-text">打开终端，切换root用户</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E6%B7%98%E5%AE%9D%E9%95%9C%E5%83%8F"><span class="toc-number">2.0.3.</span> <span class="toc-text">安装淘宝镜像</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85Hexo"><span class="toc-number">3.</span> <span class="toc-text">安装Hexo</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Hexo%E5%AE%89%E8%A3%85%E6%88%90%E5%8A%9F"><span class="toc-number">3.0.1.</span> <span class="toc-text">Hexo安装成功</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%88%9D%E5%A7%8B%E5%8C%96%E5%8D%9A%E5%AE%A2%E7%BD%91%E7%AB%99"><span class="toc-number">4.</span> <span class="toc-text">初始化博客网站</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%B0%E5%BB%BA%E9%A1%B9%E7%9B%AE%E6%96%87%E4%BB%B6%E5%A4%B9%EF%BC%8C%E5%B9%B6%E8%BF%9B%E5%85%A5%E6%96%87%E4%BB%B6%E5%A4%B9%E5%86%85"><span class="toc-number">4.0.1.</span> <span class="toc-text">新建项目文件夹，并进入文件夹内</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%90%AF%E5%8A%A8hexo"><span class="toc-number">4.0.2.</span> <span class="toc-text">启动hexo</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B5%8F%E8%A7%88%E5%99%A8%E6%89%93%E5%BC%80%E5%8D%9A%E5%AE%A2%E7%BD%91%E7%AB%99"><span class="toc-number">4.0.3.</span> <span class="toc-text">浏览器打开博客网站</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E5%8D%9A%E5%AE%A2%EF%BC%8C%E5%B9%B6%E5%86%99%E5%8D%9A%E5%AE%A2"><span class="toc-number">4.0.4.</span> <span class="toc-text">创建博客，并写博客</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E6%89%A7%E8%A1%8C"><span class="toc-number">5.</span> <span class="toc-text">项目管理执行</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B8%85%E7%90%86%E9%A1%B9%E7%9B%AE%E7%BC%93%E5%AD%98"><span class="toc-number">5.0.1.</span> <span class="toc-text">清理项目缓存</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%87%8D%E6%96%B0%E7%94%9F%E6%88%90%E9%A1%B9%E7%9B%AE"><span class="toc-number">5.0.2.</span> <span class="toc-text">重新生成项目</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%86%8D%E6%AC%A1%E5%90%AF%E5%8A%A8%E9%A1%B9%E7%9B%AE"><span class="toc-number">5.0.3.</span> <span class="toc-text">再次启动项目</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E4%B8%BB%E9%A2%98"><span class="toc-number">6.</span> <span class="toc-text">修改主题</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%89%E6%8B%A9%E4%B8%BB%E9%A2%98"><span class="toc-number">6.0.1.</span> <span class="toc-text">选择主题</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%8B%E8%BD%BD%E4%B8%BB%E9%A2%98%E4%BB%A3%E7%A0%81"><span class="toc-number">6.0.2.</span> <span class="toc-text">下载主题代码</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E9%A1%B9%E7%9B%AE%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%EF%BC%8C%E9%85%8D%E7%BD%AE%E4%B8%BB%E9%A2%98"><span class="toc-number">6.0.3.</span> <span class="toc-text">修改项目配置文件，配置主题</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9C%A8%E9%A1%B9%E7%9B%AE%E7%9B%AE%E5%BD%95%E4%B8%8B%E6%89%A7%E8%A1%8C%E4%BB%A5%E4%B8%8B%E5%91%BD%E4%BB%A4%E3%80%90%E9%9D%9E%E5%B8%B8%E9%87%8D%E8%A6%81%EF%BC%8C%E4%BA%B2%E6%B5%8B%E6%9C%89%E6%95%88%E3%80%91"><span class="toc-number">6.0.4.</span> <span class="toc-text">在项目目录下执行以下命令【非常重要，亲测有效】</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%87%8D%E6%96%B0%E7%94%9F%E6%88%90%E9%A1%B9%E7%9B%AE-1"><span class="toc-number">6.0.5.</span> <span class="toc-text">重新生成项目</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%87%8D%E6%96%B0%E8%BF%90%E8%A1%8C%E9%A1%B9%E7%9B%AE"><span class="toc-number">6.0.6.</span> <span class="toc-text">重新运行项目</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%B0%86%E5%8D%9A%E5%AE%A2%E9%83%A8%E7%BD%B2%E5%88%B0%E4%BA%91%E7%AB%AF%EF%BC%88GitHub%E4%B8%8A%EF%BC%8C%E9%9C%80%E8%A6%81%E6%9C%89%E8%87%AA%E5%B7%B1%E7%9A%84%E8%B4%A6%E6%88%B7%EF%BC%89"><span class="toc-number">7.</span> <span class="toc-text">将博客部署到云端（GitHub上，需要有自己的账户）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%B0%E5%BB%BA%E4%BB%93%E5%BA%93"><span class="toc-number">7.0.1.</span> <span class="toc-text">新建仓库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9C%A8%E9%A1%B9%E7%9B%AE%E7%9B%AE%E5%BD%95%E4%B8%8B%E6%89%A7%E8%A1%8C%E4%BB%A5%E4%B8%8B%E5%91%BD%E4%BB%A4"><span class="toc-number">7.0.2.</span> <span class="toc-text">在项目目录下执行以下命令</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">7.0.3.</span> <span class="toc-text">修改配置文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%83%A8%E7%BD%B2%E9%A1%B9%E7%9B%AE%E5%88%B0%E4%BA%91%E7%AB%AF"><span class="toc-number">7.0.4.</span> <span class="toc-text">部署项目到云端</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%BF%E9%97%AE%E4%BA%91%E7%AB%AF%E5%8D%9A%E5%AE%A2%E4%B8%BB%E9%A1%B5"><span class="toc-number">7.0.5.</span> <span class="toc-text">访问云端博客主页</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/codingdgsun/2022/01/17/React%E9%A1%B9%E7%9B%AEbuild%E5%A4%B1%E8%B4%A5%E4%B9%8BMiniCssExtractPlugin/" title="React项目build失败之MiniCssExtractPlugin"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/codingdgsun/img/404.jpg'" alt="React项目build失败之MiniCssExtractPlugin"/></a><div class="content"><a class="title" href="/codingdgsun/2022/01/17/React%E9%A1%B9%E7%9B%AEbuild%E5%A4%B1%E8%B4%A5%E4%B9%8BMiniCssExtractPlugin/" title="React项目build失败之MiniCssExtractPlugin">React项目build失败之MiniCssExtractPlugin</a><time datetime="2022-01-17T06:03:03.000Z" title="Created 2022-01-17 14:03:03">2022-01-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/codingdgsun/2022/01/17/React%E9%A1%B9%E7%9B%AE%E6%9E%84%E5%BB%BA%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" title="React项目构建常用命令"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/codingdgsun/img/404.jpg'" alt="React项目构建常用命令"/></a><div class="content"><a class="title" href="/codingdgsun/2022/01/17/React%E9%A1%B9%E7%9B%AE%E6%9E%84%E5%BB%BA%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" title="React项目构建常用命令">React项目构建常用命令</a><time datetime="2022-01-17T06:01:56.000Z" title="Created 2022-01-17 14:01:56">2022-01-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/codingdgsun/2022/01/17/Mac-OS%E5%88%9D%E5%A7%8B%E5%8C%96%E4%B8%80%E4%B8%AAReact%E9%A1%B9%E7%9B%AE/" title="Mac OS初始化一个React项目"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/codingdgsun/img/404.jpg'" alt="Mac OS初始化一个React项目"/></a><div class="content"><a class="title" href="/codingdgsun/2022/01/17/Mac-OS%E5%88%9D%E5%A7%8B%E5%8C%96%E4%B8%80%E4%B8%AAReact%E9%A1%B9%E7%9B%AE/" title="Mac OS初始化一个React项目">Mac OS初始化一个React项目</a><time datetime="2022-01-17T05:58:21.000Z" title="Created 2022-01-17 13:58:21">2022-01-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/codingdgsun/2022/01/17/MySQL%E8%AF%AD%E6%B3%95%E5%85%A5%E9%97%A8%EF%BC%88%E4%BA%8C%EF%BC%89/" title="MySQL语法入门（二）"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/codingdgsun/img/404.jpg'" alt="MySQL语法入门（二）"/></a><div class="content"><a class="title" href="/codingdgsun/2022/01/17/MySQL%E8%AF%AD%E6%B3%95%E5%85%A5%E9%97%A8%EF%BC%88%E4%BA%8C%EF%BC%89/" title="MySQL语法入门（二）">MySQL语法入门（二）</a><time datetime="2022-01-17T05:54:56.000Z" title="Created 2022-01-17 13:54:56">2022-01-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/codingdgsun/2022/01/17/Java%E4%B8%AD%E5%B8%B8%E8%A7%81%E9%9D%A2%E8%AF%95%E9%A2%98%E4%BA%8C%EF%BC%88%E7%AE%80%E5%8D%95%EF%BC%89/" title="Java中常见面试题二（简单）"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/codingdgsun/img/404.jpg'" alt="Java中常见面试题二（简单）"/></a><div class="content"><a class="title" href="/codingdgsun/2022/01/17/Java%E4%B8%AD%E5%B8%B8%E8%A7%81%E9%9D%A2%E8%AF%95%E9%A2%98%E4%BA%8C%EF%BC%88%E7%AE%80%E5%8D%95%EF%BC%89/" title="Java中常见面试题二（简单）">Java中常见面试题二（简单）</a><time datetime="2022-01-17T05:53:56.000Z" title="Created 2022-01-17 13:53:56">2022-01-17</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By CodingDGSun</div><div class="framework-info"><span>Framework </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>Theme </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="Back To Top"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/codingdgsun/js/utils.js"></script><script src="/codingdgsun/js/main.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>